package com.runen.wnhz.runen.ui.activity.major;

import android.content.Intent;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;

import com.runen.wnhz.runen.R;
import com.runen.wnhz.runen.common.utils.StatusBarCompatUtils;
import com.runen.wnhz.runen.data.entity.LessonListEntity;
import com.runen.wnhz.runen.di.component.ApplicationComponent;
import com.runen.wnhz.runen.ui.activity.BaseActivity;
import com.runen.wnhz.runen.ui.adapter.puadapter.CurrDetailsAdapter;
import com.runen.wnhz.runen.widget.TitleBuilder;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * Created by Administrator on 2018-04-26.
 * 课程详情界面
 */

public class CurrDetailsActivity extends BaseActivity {
    @BindView(R.id.ry_major_detail)
    RecyclerView ryMajorDetail;

    CurrDetailsAdapter mCurrDetailsAdapter;

    @Override
    protected int getLayoutView() {
        return R.layout.activity_major_detail;
    }

    @Override
    protected void onTitleClickListen(TitleBuilder.TitleButton clicked) {

    }

    @Override
    protected void initStart() {
        StatusBarCompatUtils.getInstance().TranslucentStatusBar(this, R.color.title_green);
        LessonListEntity lessonListEntity =
                (LessonListEntity) getIntent().getSerializableExtra("LessonList");
        mCurrDetailsAdapter = new CurrDetailsAdapter(this, lessonListEntity);
        ryMajorDetail.setLayoutManager(new LinearLayoutManager(this));
        ryMajorDetail.setAdapter(mCurrDetailsAdapter);
        setListener(mCurrDetailsAdapter);
    }

    private void setListener( CurrDetailsAdapter mCurrDetailsAdapter){
        mCurrDetailsAdapter.setItemClickListener(new CurrDetailsAdapter.MyItemClickListener() {
            @Override
            public void onItemClick(View view, LessonListEntity.ListBean lessonEntity) {
                startCourseDetailActivity(lessonEntity);
            }
        });
    }

    @OnClick({R.id.iv_back})
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.iv_back:
                finish();
                break;
        }
    }

    private void startCourseDetailActivity(LessonListEntity.ListBean lessonEntity){
        Intent intent = new Intent(CurrDetailsActivity.this, CourseDetailsActivity.class);
        intent.putExtra("lid",lessonEntity.getLid());
        startActivity(intent);
    }

    @Override
    public void initToolBar(TitleBuilder mTitleBuilder) {
        setToolBarVisible(View.GONE);
    }

    @Override
    public void setupAcitivtyComponent(ApplicationComponent appComponent) {

    }
}
